<?php 
defined('_JEXEC') or die('Restricted access');
$cparams = JComponentHelper::getParams ('com_media');
?>

<?php if ($this->params->get('show_page_title')) : ?>
<h2 class="componentheading<?php echo $this->params->get('pageclass_sfx'); ?>">
	<?php echo $this->escape($this->params->get('page_title')); ?>
</h2>
<?php endif; ?>

<div class="blog<?php echo $this->params->get('pageclass_sfx'); ?>">

	<?php if ($this->params->def('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
	<div class="descrizione<?php echo $this->params->get('pageclass_sfx'); ?>">
	
		<?php if ($this->params->get('show_description_image') && $this->category->image) : ?>
		<img src="<?php echo $this->baseurl .'/'. $cparams->get('image_path').'/'.$this->category->image; ?>" align="<?php echo $this->category->image_position; ?>" class="img-<?php echo $this->category->image_position; ?>"/>
		<?php endif; ?>

		<?php if ($this->params->get('show_description') && $this->category->description) :
			echo $this->category->description;
		endif; ?>

		<?php if ($this->params->get('show_description_image') && $this->category->image) : ?>
		<div class="blocca_immagine"></div>
		<?php endif; ?>

	</div>
	<?php endif; ?>

	<?php $i = $this->pagination->limitstart;
	$righe = $this->params->def('num_leading_articles', 1);
	for ($y = 0; $y < $righe && $i < $this->total; $y++, $i++) : ?>
		<div class="principale<?php echo $this->params->get('pageclass_sfx'); ?>">
			<?php $this->item =& $this->getItem($i, $this->params);
			echo $this->loadTemplate('item'); ?>
		</div>
		
	<?php endfor; ?>

	<?php $introduzioni = $this->params->def('num_intro_articles', 4);
	if ($introduzioni) :
		$colonne = $this->params->def('num_columns', 2);
		if ($colonne == 0) :
			$colonne = 1;
		endif;
		$righe = (int) $introduzioni / $colonne;
		$ii = 0;
		for ($y = 0; $y < $righe && $i < $this->total; $y++) : ?>
			<div class="riga<?php echo $this->params->get('pageclass_sfx'); ?>">
				<?php for ($z = 0; $z < $colonne && $ii < $introduzioni && $i < $this->total; $z++, $i++, $ii++) : ?>
					<div class="article">
						<?php $this->item =& $this->getItem($i, $this->params);
						echo $this->loadTemplate('item'); ?>
					</div>
					
				<?php endfor; ?>
				
			</div>
		<?php endfor;
	endif; ?>

	<?php $numerolink = $this->params->def('num_links', 4);
	if ($numerolink && $i < $this->total) : ?>
	<div class="blog_more<?php echo $this->params->get('pageclass_sfx'); ?> blog_more_general" >
		<?php $this->links = array_slice($this->items, $i - $this->pagination->limitstart, $i - $this->pagination->limitstart + $numerolink);
		echo $this->loadTemplate('links'); ?>
	</div>
	<?php endif; ?>

	<?php if ($this->params->def('show_pagination', 2) == 1  || ($this->params->get('show_pagination') == 2 && $this->pagination->get('pages.total') > 1)) : ?>
		<?php if( $this->pagination->get('pages.total') > 1 ) : ?>
		<div class="pagination-block">
		<div class="contatore">
			<?php echo $this->pagination->getPagesCounter(); ?>
		</div>
		<?php endif; ?>
		<?php if ($this->params->def('show_pagination_results', 1)) : ?>
		
			<?php echo $this->pagination->getPagesLinks(); ?>
		
		<?php endif; ?>
		</div>
	<?php endif; ?>

</div>
